package com.shop.cereshop.business.dl.logic.controller;

import com.shop.cereshop.business.dl.logic.domain.CereShopCarousel;
import com.shop.cereshop.business.dl.logic.service.CereShopCarouselService;
import com.shop.cereshop.business.dl.logic.utils.ResultInfo;
import com.shop.cereshop.commons.utils.TimeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @program: dlshop
 * 描述：
 * @author: 我好帅
 * @create: 2021-07-06 20:10
 **/
@RestController
@RequestMapping("/business/carousel")
public class CereShopCarouselController {
    @Autowired
    private CereShopCarouselService cereShopCarouselService;

    @PostMapping("/select")
    public ResultInfo select(Integer page,Integer row){
        ResultInfo r = cereShopCarouselService.select(page,row);
        return r;
    }
    @PostMapping("/selectById")
    public ResultInfo selectById(Long carousel){
        ResultInfo r = cereShopCarouselService.selectById(carousel);
        return r;
    }

    @PostMapping("/add")
    public ResultInfo add(CereShopCarousel obj){
        ResultInfo info = null;
        //id不存在,表示新增
        String str = TimeUtils.yyMMddHHmmss();
        obj.setCreateTime(str);
        if (obj.getCarousel()==null){
            info = cereShopCarouselService.add(obj);
        }else {
            info = cereShopCarouselService.update(obj);
        }
        return info;
    }
    @PostMapping("/delete")
    public ResultInfo delete(Long carousel){
        ResultInfo r = cereShopCarouselService.delete(carousel);
        return r;
    }
    @PostMapping("/enableDisable")
    public ResultInfo enableDisable(Long carousel,Byte state){
        ResultInfo r = cereShopCarouselService.enableDisable(carousel,state);
        return r;
    }
}
